package com.jh.paymentchannel.business;

import cn.jh.common.exception.ServiceException;
import com.alipay.api.response.AlipayTradePrecreateResponse;
import com.google.common.collect.Range;
import com.jh.paymentchannel.payment.OrderType;
import com.jh.paymentchannel.payment.PaymentException;
import com.jh.paymentchannel.payment.PaymentRequest;
import com.jh.paymentchannel.payment.TradeStatus;
import com.jh.paymentchannel.pojo.PaymentOrder;
import com.jh.paymentchannel.pojo.PaymentView;
import com.jh.paymentchannel.pojo.TaiwanCardOrder;
import com.jh.paymentchannel.pojo.UserTurnover;
import com.sun.corba.se.spi.activation.Server;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;

import javax.validation.constraints.Digits;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * @author Yichuan
 * @version 1.0
 */
public interface PaymentOrderBusiness {

    /**
     * 处理客服端支付宝支付请求
     *
     * @param request 支付请求数据
     * @return 返回支付响应数据
     * @throws PaymentException 处理发生异常时抛出
     */
    String createAlipayOrder(PaymentRequest request) throws PaymentException;

    /**
     * 支付宝扫码当面付
     *
     * @param request 支付请求数据
     * @return 返回支付响应数据
     * @throws PaymentException 处理发生异常时抛出
     */
    AlipayTradePrecreateResponse alipayPrecreateOrder(PaymentRequest request) throws PaymentException;

    /**
     * 处理客服端微信支付请求
     *
     * @param request 支付请求数据
     * @return 返回支付响应数据
     * @throws PaymentException 处理发生异常时抛出
     */
    Map<String, String> createWechatOrder(PaymentRequest request) throws PaymentException;

    /**
     * 处理订单异步回调业务
     *
     * @param params    回调数据
     * @param orderType 订单类型
     * @throws PaymentException 业务异常时抛出
     */
    void notifyPaymentOrder(Map<String, String> params, OrderType orderType) throws PaymentException;

    /**
     * 查询指定支付订单信息
     *
     * @param outTradeNo 订单号
     * @return 返回订单信息
     */
    PaymentOrder findPaymentOrder(String outTradeNo);

    /**
     * 支付订单补单
     *
     * @param outTradeNo 支付订单号
     * @return 返回支付订单信息
     */
    PaymentOrder supplyPaymentOrder(String outTradeNo) throws PaymentException;

    /**
     * 分页查询支付订单信息
     *
     * @param userId      用户id
     * @param orderType   订单类型
     * @param tradeStatus 交易状态
     * @param pageable    分页参数
     * @return 返回支付订单信息集合
     */
    Page<PaymentOrder> findPaymentOrder(String agent, Long userId, OrderType orderType, TradeStatus tradeStatus, Pageable pageable) throws ServiceException;

    Map<String, Object> conditionalQuery(long userId, OrderType orderType, String startTime, String endTime, String minTotalFee, String maxTotalFee,
                                               String shopPhone, String shopName, Pageable pageable) throws ServiceException;

    /**
     * 台卡扫码订单创建
     * @param view
     */
    Map<String, String> addPayment(PaymentView view);

    /**
     * app查询扫码支付订单列表
     */
    Map<String,Object> queryPayOrder(PaymentView view, Pageable pageable);

    /**
     * 查询扫码支付订单详细信息
     */
    PaymentView queryPayOrder(String orderNo);

    /**
     * 运营后台查询扫码支付订单列表
     */
    Map<String,Object>  queryPayOrderList(PaymentView view,Pageable pageable);

    /**
     * 同步订单状态
     */
    void synOrder();



    /**
     * 查询昨日交易额
     */
    String queryYesAmount(PaymentView view);

    /**
     * 更新商户代理分润清算状态
     */
    void updateOrderSelStatus(PaymentView view);

    Map<String, Object> getPayOrderPage(String phone, String orderNo, String selStatus, String startTime, String endTime, Pageable pageable) throws ServiceException;
}
